package treepro;

import java.awt.Color;
import java.awt.Component;
import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.ListCellRenderer;
import javax.swing.table.JTableHeader;

/**
 *
 * @author Ivan
 */
class RowHeaderRenderer extends JLabel implements ListCellRenderer {

    private final JTableHeader header;

    public RowHeaderRenderer(JTableHeader header) {
        this.header = header;
        this.setOpaque(true);
        //
        this.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 2, Color.GRAY));
        this.setHorizontalAlignment(CENTER);
        this.setForeground(header.getForeground());
        this.setBackground(header.getBackground());
        this.setFont(header.getFont());
    }

    public Component getListCellRendererComponent(JList list, Object value,
            int index, boolean isSelected, boolean cellHasFocus) {

        setForeground(header.getForeground());
        setBackground(header.getBackground());

        setText((value == null) ? "" : value.toString());
        return this;
    }
}
